﻿<Page
	 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
	  x:Class="MovieRental_Presentation.Cart" 
      d:DesignWidth="250" d:DesignHeight="400"
      mc:Ignorable="d" 
      ShowsNavigationUI="False">

	<Grid x:Name="LayoutRoot" Background="{StaticResource backgroundBrush}" DataContext="{Binding CurrentCart}">
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="Auto"/>
			<ColumnDefinition/>
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
		</Grid.RowDefinitions>
		<Label Content="Cart" HorizontalAlignment="Center" Foreground="{StaticResource borderBrush}" BorderThickness="0" Margin="0" VerticalAlignment="Center" Grid.ColumnSpan="2" Style="{StaticResource MenuLabelStyle}"/>
		<TextBlock Grid.Column="0" VerticalAlignment="Center" Foreground="{StaticResource inputBoxBrush}" FontSize="{StaticResource infoTextSize}" Margin="0" Grid.Row="1" HorizontalAlignment="Left" Visibility="{Binding Text, Converter={StaticResource stringLengthVisibilityConverter}, ElementName=customerNameTextBlock}" ><Run Text="Customer:"/></TextBlock>
		<ListBox Grid.Row="2" Grid.ColumnSpan="2" Margin="0,8,0,0" ItemsSource="{Binding Loans}" Name="loansList" ItemContainerStyle="{StaticResource GeneralItemStyle}" Style="{DynamicResource CartStyle}" ItemTemplate="{DynamicResource LoanTemplate}" />
		<Button Content="Delete" Margin="0,8,0,0" Grid.Row="3" Grid.ColumnSpan="2" VerticalAlignment="Center" Height="30" Name="deleteButton" Click="deleteButton_Click" Visibility="{Binding SelectedIndex, Converter={StaticResource indexVisibilityConverter}, ElementName=loansList}" />
		<TextBlock Grid.Column="0" Foreground="{StaticResource inputBoxBrush}" FontSize="{StaticResource infoTextSize}" Margin="0,5,0,0" Grid.Row="4" HorizontalAlignment="Left" Text="Initial Cost:" VerticalAlignment="Center" />
		<TextBlock Grid.Column="0" Foreground="{StaticResource inputBoxBrush}" FontSize="{StaticResource infoTextSize}" Margin="0,5,0,0" Grid.Row="5" HorizontalAlignment="Left" Text="Discount:" VerticalAlignment="Center" />
		<Border BorderBrush="{StaticResource borderBrush}" Margin="0,3,0,0" Grid.Row="6" Height="2" VerticalAlignment="Top" Grid.ColumnSpan="2" BorderThickness="1"/>
		<TextBlock Grid.Column="0" Foreground="{StaticResource inputBoxBrush}" FontSize="{StaticResource infoTextSize}" Margin="0,5,0,0" Grid.Row="7" HorizontalAlignment="Left" Text="Total Cost:" VerticalAlignment="Center" />
		<TextBlock Name="customerNameTextBlock" Text="{Binding CustomerName}" Grid.Column="1" VerticalAlignment="Center" Foreground="{StaticResource inputBoxBrush}" FontSize="{StaticResource infoTextSize}" Margin="8,0,0,0" Grid.Row="1" HorizontalAlignment="Left" Visibility="{Binding Text, Converter={StaticResource stringLengthVisibilityConverter}, ElementName=customerNameTextBlock}"/>
		<TextBlock Text="{Binding Path=InitialCost, StringFormat=\{0:c\}}" Grid.Column="1" Foreground="{StaticResource inputBoxBrush}" FontSize="{StaticResource infoTextSize}" Margin="0,8,0,0" Grid.Row="4" HorizontalAlignment="Right"  VerticalAlignment="Center" />
		<TextBlock Text="{Binding Path=Entity.CartDiscountValue,StringFormat=\{0\}%}" Grid.Column="1" Foreground="{StaticResource inputBoxBrush}" FontSize="{StaticResource infoTextSize}" Margin="0,8,0,0" Grid.Row="5" HorizontalAlignment="Right" />
		<TextBlock Text="{Binding Path=TotalCost, StringFormat=\{0:c\}}" Grid.Column="1" Foreground="{StaticResource inputBoxBrush}" FontSize="{StaticResource infoTextSize}" Margin="0,8,0,0" Grid.Row="7" HorizontalAlignment="Right"/>
		<Grid Grid.Row="8" Grid.ColumnSpan="2">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="*"/>
				<ColumnDefinition Width="*"/>
			</Grid.ColumnDefinitions>
			<Button x:Name="acceptButton" Content="Accept" Margin="0,5,5,0" Height="25" VerticalAlignment="Top" Click="acceptButton_Click">
				<Button.IsEnabled>
					<MultiBinding Converter="{StaticResource cartApplyButtonEnabledConverter}">
						<Binding ElementName="customerNameTextBlock" Path="Text"/>
						<Binding ElementName="loansList" Path="HasItems"/>
					</MultiBinding>
				</Button.IsEnabled>
			</Button>
			<Button Content="Clear" Margin="5,5,0,0"  Height="25" VerticalAlignment="Top" Grid.Column="1" Name="clearButton" Click="clearButton_Click" />
		</Grid>
	</Grid>
</Page>